// P1135 bfs AC
#include <iostream>
#include <cstdio>
#include <queue>
#include <cstring>

#define N 205

using namespace std;

int to[N];	//能上（下）多少层
bool vis[N];//去没去过
int ans[N];
int n, a, b;

void bfs(){
	memset(ans, -1, sizeof(ans));	memset(vis, false, sizeof(vis));
	queue < pair<int, int> > q; // first == floor;	second == step(stp)
	q.push(make_pair(a, 0));
	int flr;	int curstp = 0;
	while(!q.empty()){
		flr = q.front().first;	curstp = q.front().second;	q.pop();
		ans[flr] = curstp;
		if(flr + to[flr] <= n && !vis[flr + to[flr]]){
			q.push( make_pair(flr + to[flr], curstp + 1));
			vis[flr + to[flr]] = true;
		}
		if(flr - to[flr] >= 1 && !vis[flr - to[flr]]){
			q.push( make_pair(flr - to[flr], curstp + 1));
			vis[flr - to[flr]] = true;
		}
	}
}

int main(){
	cin >> n >> a >> b;
	for(int i = 1; i<= n; i++){
		scanf("%d", &to[i]);
	}
	if(a == b){
		cout << 0 << endl;
		return 0;
	}
	bfs();
	cout << ans[b] << endl;
	return 0;
}